package com.zgh.rbac.service;

import com.xxg.base.module.Operater;
import com.xxg.base.module.Page;
import com.xxg.base.module.PageData;
import com.xxg.exception.BaseException;
import com.zgh.rbac.module.*;

import java.util.List;
import java.util.Map;

public interface IRbacService {
	
	//菜单
	public Menu saveOrUpdateMenu(Menu menu, Operater operater)throws BaseException;
	public Menu getMenu(Long menuId, Operater operater)throws BaseException;
	public List<Menu> listMenu(Map<String, Object> params, Operater operater, PageData pageData)throws BaseException;
	public Integer countMenu(Map<String, Object> params, Operater operater)throws BaseException;
	public Page<Menu> showMenuPage(Page<Menu> page, Operater operater)throws BaseException;

	public void disableMenu(Long menuId, Operater operater)throws BaseException; //不启用
	public void enableMenu(Long menuId, Operater operater)throws BaseException;  //启用
	public void deleteMenu(Long menuId, Operater operater)throws BaseException; //删除
	public void cancelDeleteMenu(Long menuId, Operater operater)throws BaseException; //还原


	//角色-对下级角色的管理
	public Role saveOrUpdateRole(Role role, Operater operater)throws BaseException;
	public Role getRole(Long roleId, Operater operater)throws BaseException;
	public List<Role> listRole(Map<String, Object> params, Operater operater, PageData pageData)throws BaseException;
	public Integer countRole(Map<String, Object> params, Operater operater)throws BaseException;
	public Page<Role> showRolePage(Page<Role> page, Operater operater)throws BaseException;

	//角色与菜单
	public void saveOrUpdateRoleAndMenus(List<RoleAndMenu> list, Operater operater)throws BaseException;
	public RoleAndMenu saveOrUpdateRoleAndMenu(RoleAndMenu roleAndMenu, Operater operater)throws BaseException;
	public void deleteRoleAndMenu(Long roleAndMenuId, Operater operater)throws BaseException;
	public List<RoleAndMenu> listRoleAndMenu(Map<String, Object> params, Operater operater, PageData pageData)throws BaseException;
	public Integer countRoleAndMenu(Map<String, Object> params, Operater operater)throws BaseException;
	public Page<RoleAndMenu> showRoleAndMenuPage(Page<RoleAndMenu> page, Operater operater)throws BaseException;

	//角色的数据权限-用户
	public void saveOrUpdateRoleAndUsers(List<RoleAndUser> list, Operater operater)throws BaseException;
	public RoleAndUser saveOrUpdateRoleAndUser(RoleAndUser roleAndUser, Operater operater)throws BaseException;
	public void deleteRoleAndUser(Long roleAndUserId, Operater operater)throws BaseException;
	public List<RoleAndUser> listRoleAndUser(Map<String, Object> params, Operater operater, PageData pageData)throws BaseException;
	public Integer countRoleAndUser(Map<String, Object> params, Operater operater)throws BaseException;
	public Page<RoleAndUser> showRoleAndUserPage(Page<RoleAndUser> page, Operater operater)throws BaseException;

	//角色的数据权限-组织
	public void saveOrUpdateRoleAndOrganizations(List<RoleAndOrganization> list, Operater operater)throws BaseException;
	public RoleAndOrganization saveOrUpdateRoleAndOrganization(RoleAndOrganization roleAndOrganization, Operater operater)throws BaseException;
	public void deleteRoleAndOrganization(Long roleAndOrganizationId, Operater operater)throws BaseException;
	public List<RoleAndOrganization> listRoleAndOrganization(Map<String, Object> params, Operater operater, PageData pageData)throws BaseException;
	public Integer countRoleAndOrganization(Map<String, Object> params, Operater operater)throws BaseException;
	public Page<RoleAndOrganization> showRoleAndOrganizationPage(Page<RoleAndOrganization> page, Operater operater)throws BaseException;

	//角色的成员-用户
	public void saveOrUpdateUserAndRoles(List<UserAndRole> list, Operater operater)throws BaseException;
	public UserAndRole saveOrUpdateUserAndRole(UserAndRole userAndRole, Operater operater)throws BaseException;
	public void deleteUserAndRole(Long userAndRoleId, Operater operater)throws BaseException;
	public List<UserAndRole> listUserAndRole(Map<String, Object> params, Operater operater, PageData pageData)throws BaseException;
	public Integer countUserAndRole(Map<String, Object> params, Operater operater)throws BaseException;
	public Page<UserAndRole> showUserAndRolePage(Page<UserAndRole> page, Operater operater)throws BaseException;

	//角色的成员-组织
	public void saveOrUpdateOrganizationAndRoles(List<OrganizationAndRole> list, Operater operater)throws BaseException;
	public OrganizationAndRole saveOrUpdateOrganizationAndRole(OrganizationAndRole organizationAndRole, Operater operater)throws BaseException;
	public void deleteOrganizationAndRole(Long organizationAndRoleId, Operater operater)throws BaseException;
	public List<OrganizationAndRole> listOrganizationAndRole(Map<String, Object> params, Operater operater, PageData pageData)throws BaseException;
	public Integer countOrganizationAndRole(Map<String, Object> params, Operater operater)throws BaseException;
	public Page<OrganizationAndRole> showOrganizationAndRolePage(Page<OrganizationAndRole> page, Operater operater)throws BaseException;

	//管理角色管理的-人
	public void saveOrUpdateAdminRoleAndUsers(List<AdminRoleAndUser> list, Operater operater)throws BaseException;
	public AdminRoleAndUser saveOrUpdateAdminRoleAndUser(AdminRoleAndUser adminRoleAndUser, Operater operater)throws BaseException;
	public void deleteAdminRoleAndUser(Long adminRoleAndUserId, Operater operater)throws BaseException;
	public List<AdminRoleAndUser> listAdminRoleAndUser(Map<String, Object> params, Operater operater, PageData pageData)throws BaseException;
	public Integer countAdminRoleAndUser(Map<String, Object> params, Operater operater)throws BaseException;
	public Page<AdminRoleAndUser> showAdminRoleAndUserPage(Page<AdminRoleAndUser> page, Operater operater)throws BaseException;

	//管理角色管理的-组织
	public void saveOrUpdateAdminRoleAndOrganizations(List<AdminRoleAndOrganization> list, Operater operater)throws BaseException;
	public AdminRoleAndOrganization saveOrUpdateAdminRoleAndOrganization(AdminRoleAndOrganization adminRoleAndOrganization, Operater operater)throws BaseException;
	public void deleteAdminRoleAndOrganization(Long adminRoleAndOrganizationId, Operater operater)throws BaseException;
	public List<AdminRoleAndOrganization> listAdminRoleAndOrganization(Map<String, Object> params, Operater operater, PageData pageData)throws BaseException;
	public Integer countAdminRoleAndOrganization(Map<String, Object> params, Operater operater)throws BaseException;
	public Page<AdminRoleAndOrganization> showAdminRoleAndOrganizationPage(Page<AdminRoleAndOrganization> page, Operater operater)throws BaseException;

	//查出本人的菜单及菜单对应的数据权限
	public List<Menu> listMenuAndDataPower(Long menuId, Long roleId, Operater operater)throws BaseException;
	//查出指定人员或组织的菜单及对应的数据权限
	public List<Menu> listMenuAndDataPowerByUser(Long menuId, Long roleId, Long userId, Operater operater)throws BaseException;
	public List<Menu> listMenuAndDataPowerByOrganization(Long menuId, Long roleId, Long organizationId, String organizationCode, String organization, Operater operater)throws BaseException;

	//查询默认角色的菜单及对应的权限
	public List<Menu> listMenuAndDataPowerLabour();
	public List<Menu> listMenuAndDataPowerStaff();
	public List<Menu> listMenuAndDataPowerLabourUnion();


	//查询出角色的数据权限对应的人员ids
	public String getPowerUserIdsByRole(Long roleId)throws BaseException;
	//查询出角色的数据权限对应的组织codes
	public String getPowerOrganizationCodesByRole(Long roleId, Long creater)throws BaseException;

	//查询出管理角色管理范围对应的人员ids
	public String getAdminRoleUserIds(Long roleId)throws BaseException;
	//查询出管理角色管理范围对应的组织codes
	public String getAdminRoleOrganizationCodes(Long roleId)throws BaseException;

	//查询出用户对应的全部角色
	List<Role> listRoleByUserId(Long userId, Operater operater)throws BaseException;
	//查询出组织对应的全部角色
	List<Role> listRoleByOrganization(Long organizationId, String organizationCode, String organization, Operater operater)throws BaseException;
	
	//检查是否超级管理员
	public String superAdmin(Operater operater);
	
	//清理缓存，加载数据到缓存
	public void clearMenuRedisCache();
	public int loadMenuToRedisCache(String menuIds);
	public void clearRoleRedisCache();
	public int loadRoleToRedisCache(String roleIds);
	
}
